﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<skags.Models.ThreadViewModel>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Spjallið - <%= ViewData["CategoryName"] %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div id="main">
    
    <br /><br />
    <div class="forumCategory"><%: Html.ActionLink("Spjallið", "Index") %> | <%= ViewData["CategoryName"] %></div>
    
    <% if ((ViewData["CategoryName"] == ("Stjórnendaspjall") && ((HttpContext.Current.User.IsInRole("Admin")) == false ))) { %>
                    
                     <h2> Þetta spjallborð er aðeins fyrir stjórnendur. </h2>
    <% } %>
    

        <% else { %>

        <table>
        <tr>
            <th width="4%"><a href="/Forum/CreateThread/<%= ViewData["CategoryID"] %>"><img src="../../Content/icons/create.png" alt="Nýr þráður" /></a></th>
            <th width="24%">
                Titill
            </th>
            <th width="20%">
                Höfundur
            </th>
            <th width="16%">
                Dags
            </th>
            
            <th width="36%">
                Innihald
            </th>
        </tr>
        
        <% foreach (var item in Model) { %> 
           
        <tr>
            <td>
            <% if (HttpContext.Current.User.Identity.Name == item.UserName) {%>
            
                <a href="/Forum/DeleteThread/<%=item.ID%>" onclick="return confirm('Ertu viss um að þú viljir eyða þessum þráð?')"><img src="../../Content/icons/delete.png" alt="Eyða" /></a>
                <a href="/Forum/Edit/<%=item.ID%>"><img src="../../Content/icons/edit.png" alt="Breyta" /></a>
                
            <% }%>
                    
            </td>
            <td>
                <%:Html.ActionLink( item.Title, "Thread", new {id = item.ID})%> 
            </td>
            <td>
                <p class="news_author"><a href="/Profile/User/<%=item.AuthorIntID%>"><%=item.UserName%></a></p>
            </td>
            <td>
                <%:String.Format("{0:g}", item.DateCreated)%>
            </td>
            
            <td>
                <% if (item.ThreadText.Length > 100) { %>
                <%:item.ThreadText.Substring(0, 100) %>...
                <% } %>
                <% else { %>
                <%:item.ThreadText %>
                <% } %>
            </td>
        </tr>

            

    <% } %>
    </table>
    <% } %>
</div>
</asp:Content>
